#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int maxConsecutiveAnswers(string answerKey, int k) {
        int hash[2]{};
        int l = 0, r = 0;
        int n = answerKey.size();
        while (r < n)
        {
            hash[answerKey[r] - 'F' ? 1 : 0]++;
            if (hash[0] > k && hash[1] > k)
            {
                hash[answerKey[l] - 'F' ? 1 : 0]--;
                l++;
            }
            r++;
        }
        return n - l;
    }
};